package com.kykj.kykj.service.impl;

import com.kykj.kykj.dao.ArticlesDao;
import com.kykj.kykj.entity.ArticlesEntity;
import com.kykj.kykj.service.ArticlesService;
import com.kykj.kykj.vo.ArticlesVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ArticlesServiceImpl implements ArticlesService {
    @Resource
    ArticlesDao articlesDao;

    @Override
    public List<ArticlesEntity> getArticlesList() {
        return articlesDao.getArticlesList();
    }

    @Override
    public int addArticle(ArticlesVo articlesVo) {
        return  articlesDao.addArticle(articlesVo);
    }

    @Override
    public int delArticle(int id) {
        return articlesDao.delArticle(id);
    }

    @Override
    public int upArticle(ArticlesVo articlesVo) {
        return articlesDao.upArticle(articlesVo);
    }

    @Override
    public List<ArticlesEntity> getArticleByfieId(String title, String tags, int start, int limit) {
        if(!title.equals("")){
            title="%"+title+"%";
        }
        if(!tags.equals("")){
            tags="%"+tags+"%";
        }
        return articlesDao.getArticleByfieId(title,tags,start,limit);
    }

    @Override
    public int getArticlesCount() {
        return articlesDao.getArticlesCount();
    }

    @Override
    public int upCover(String cover, int id) {
        return articlesDao.upCover(cover,id);
    }

    @Override
    public List<ArticlesEntity> getArticlesByUserid(int userId) {
        return articlesDao.getArticlesByUserid(userId);
    }
}
